package com.ss.android.action.b;

import android.content.Context;
import android.view.View;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;

public abstract class BaseFeedAdapter extends BaseAdapter implements AbsListView.RecyclerListener, a {
    public boolean isPaused = true;
    public boolean b = true;
    public b c;
    public WeakReference<ListView> mRefListView;
    public Context mContext;

    public BaseFeedAdapter(Context context) {
        this.mContext = context;
    }

    public final void setListView(ListView listView) {
        if (listView != null) {
            this.mRefListView = new WeakReference(listView);
        } else {
            this.mRefListView = null;
        }

    }

    public boolean a() {
        return this.isPaused;
    }

    public boolean a(int arg2, FeedViewHolder arg3) {
        return this.isPaused;
    }

    public final List b() {
        List v0;
        Object v1 = null;
        ListView v4 = this.getListView();
        if (v4 == null) {
            v0 = ((List) v1);
        } else {
            ArrayList v2 = new ArrayList();
            int v5 = v4.getChildCount();
            int v3;
            for (v3 = 0; v3 < v5; ++v3) {
                Object v0_1 = v4.getChildAt(v3).getTag();
                if (!(v0_1 instanceof FeedViewHolder)) {
                    v0_1 = v1;
                }

                if (v0_1 != null) {
                    ((List) v2).add(v0_1);
                }
            }
            v0 = v2;
        }

        return v0;
    }

    public final ListView getListView() {
        if (this.mRefListView != null) {
            return this.mRefListView.get();
        } else {
            return null;
        }
    }

    public b d() {
        return this.c;
    }

    public final void e() {
        if (this.c == null) {
            this.c = this.d();
        }
    }

    public final void f() {
        this.e();
        if (this.c != null) {
            this.c.a(((a) this));
            this.b = false;
        }
    }

    public final void g() {
        if (!this.b) {
            this.e();
            if (this.c != null) {
                this.c.b(((a) this));
                this.b = true;
            }
        }
    }

    public void onMovedToScrapHeap(View view) {
        Object obj = view != null ? view.getTag() : null;
        if ((obj instanceof FeedViewHolder)) {
            this.e();
            if (this.c != null && obj != null) {
                this.c.b(((FeedViewHolder) obj));
            }
            ((FeedViewHolder) obj).a();
        }
    }
}

